//
//  IRestaurant.m
//  XRmenu
//
//  Created by yangxh on 11-3-24.
//  Copyright 2011 E0571. All rights reserved.
//

#import "IRestaurant.h"


@implementation IRestaurant

@synthesize hotelName;
@synthesize restaurantName;

//=========================================================== 
// - (id)init
//
//=========================================================== 
- (id)init
{
	return [self initWithHotelName:nil restaurantName:nil];
}


//=========================================================== 
// - (id)initWith:
//
//=========================================================== 
- (id)initWithHotelName:(NSString*)anHotelName restaurantName:(NSString*)aRestaurantName 
{
    self = [super init];
    if (self) {
        self.hotelName = anHotelName;
        self.restaurantName = aRestaurantName;
    }
    return self;
}


//=========================================================== 
// + (id)objectWith:
//
//=========================================================== 
+ (id)objectWithHotelName:(NSString*)anHotelName restaurantName:(NSString*)aRestaurantName  
{
    id result = [[[self class] alloc] initWithHotelName:anHotelName restaurantName:aRestaurantName];
	
    return [result autorelease];
}

//=========================================================== 
// - (NSArray *)keyPaths
//
//=========================================================== 
- (NSArray *)keyPaths
{
    NSArray *result = [NSArray arrayWithObjects:
					   @"hotelName",
					   @"restaurantName",
					   nil];
	
    return result;
}


//=========================================================== 
// - (NSString *)descriptionForKeyPaths
//
//=========================================================== 
- (NSString *)descriptionForKeyPaths 
{
    NSMutableString *desc = [NSMutableString string];
    NSEnumerator *e = [[self keyPaths] objectEnumerator];
    NSString *thisKey;
    [desc appendString:@"\n\n"];
	
    while ((thisKey = [e nextObject])) {
        [desc appendFormat: @"%@: %@\n", thisKey, [self valueForKey:thisKey]];
    }
	
    return [NSString stringWithString:desc];
}

- (NSString *)description
{
	return [self descriptionForKeyPaths];
}

//=========================================================== 
// dealloc
//=========================================================== 
- (void)dealloc
{
    [hotelName release];
    hotelName = nil;
    [restaurantName release];
    restaurantName = nil;
	
    [super dealloc];
}

+ (IRestaurant *)iRestaurantByParse:(NSDictionary *)info
{
	IRestaurant *rest = [IRestaurant objectWithHotelName:[info objectForKey:@"HotelName"] restaurantName:[info objectForKey:@"RestaurantName"]];
	return rest;
}

@end
